package cn.iocoder.yudao.module.system.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 大学类型枚举
 * 包含985、211院校名单
 *
 * @author 芋道源码
 */
@Getter
@AllArgsConstructor
public enum UniversityTypeEnum {

    // 985院校（39所）
    TSINGHUA("清华大学", new String[]{"985", "211", "双一流"}),
    PEKING("北京大学", new String[]{"985", "211", "双一流"}),
    FUDAN("复旦大学", new String[]{"985", "211", "双一流"}),
    SHANGHAI_JIAOTONG("上海交通大学", new String[]{"985", "211", "双一流"}),
    ZHEJIANG("浙江大学", new String[]{"985", "211", "双一流"}),
    NANJING("南京大学", new String[]{"985", "211", "双一流"}),
    XIAN_JIAOTONG("西安交通大学", new String[]{"985", "211", "双一流"}),
    HARBIN_INSTITUTE("哈尔滨工业大学", new String[]{"985", "211", "双一流"}),
    BEIHANG("北京航空航天大学", new String[]{"985", "211", "双一流"}),
    BEIJING_INSTITUTE("北京理工大学", new String[]{"985", "211", "双一流"}),
    TIANJIN("天津大学", new String[]{"985", "211", "双一流"}),
    DALIAN_TECH("大连理工大学", new String[]{"985", "211", "双一流"}),
    SOUTHEAST("东南大学", new String[]{"985", "211", "双一流"}),
    HUAZHONG_TECH("华中科技大学", new String[]{"985", "211", "双一流"}),
    NORTHWESTERN_POLY("西北工业大学", new String[]{"985", "211", "双一流"}),
    CENTRAL_SOUTH("中南大学", new String[]{"985", "211", "双一流"}),
    SICHUAN("四川大学", new String[]{"985", "211", "双一流"}),
    ELECTRONIC_TECH("电子科技大学", new String[]{"985", "211", "双一流"}),
    SUN_YAT_SEN("中山大学", new String[]{"985", "211", "双一流"}),
    SOUTH_CHINA_TECH("华南理工大学", new String[]{"985", "211", "双一流"}),
    SHANDONG("山东大学", new String[]{"985", "211", "双一流"}),
    XIAMEN("厦门大学", new String[]{"985", "211", "双一流"}),
    TONGJI("同济大学", new String[]{"985", "211", "双一流"}),
    BEIJING_NORMAL("北京师范大学", new String[]{"985", "211", "双一流"}),
    NANKAI("南开大学", new String[]{"985", "211", "双一流"}),
    WUHAN("武汉大学", new String[]{"985", "211", "双一流"}),
    HUNAN("湖南大学", new String[]{"985", "211", "双一流"}),
    JILIN("吉林大学", new String[]{"985", "211", "双一流"}),
    CHONGQING("重庆大学", new String[]{"985", "211", "双一流"}),
    LANZHOU("兰州大学", new String[]{"985", "211", "双一流"}),
    NORTHEAST("东北大学", new String[]{"985", "211", "双一流"}),
    RENMIN("中国人民大学", new String[]{"985", "211", "双一流"}),
    BEIJING_AGRI("中国农业大学", new String[]{"985", "211", "双一流"}),
    OCEAN("中国海洋大学", new String[]{"985", "211", "双一流"}),
    MINZU("中央民族大学", new String[]{"985", "211", "双一流"}),
    NATIONAL_DEFENSE("国防科技大学", new String[]{"985", "211", "双一流"}),
    NORTHWEST_AGRI("西北农林科技大学", new String[]{"985", "211", "双一流"}),
    EAST_CHINA_NORMAL("华东师范大学", new String[]{"985", "211", "双一流"}),
    CENTRAL_FINANCE("中央财经大学", new String[]{"211", "双一流"}),

    // 211院校（非985的211院校）
    BEIJING_JIAOTONG("北京交通大学", new String[]{"211", "双一流"}),
    BEIJING_TECH("北京科技大学", new String[]{"211", "双一流"}),
    BEIJING_CHEMICAL("北京化工大学", new String[]{"211"}),
    BEIJING_POST("北京邮电大学", new String[]{"211", "双一流"}),
    BEIJING_FORESTRY("北京林业大学", new String[]{"211", "双一流"}),
    BEIJING_CHINESE_MED("北京中医药大学", new String[]{"211", "双一流"}),
    BEIJING_FOREIGN("北京外国语大学", new String[]{"211", "双一流"}),
    COMMUNICATION_CHINA("中国传媒大学", new String[]{"211", "双一流"}),
    CHINA_POLITICAL_LAW("中国政法大学", new String[]{"211", "双一流"}),
    NORTH_CHINA_ELECTRIC("华北电力大学", new String[]{"211", "双一流"}),
    CHINA_MINING_BEIJING("中国矿业大学（北京）", new String[]{"211", "双一流"}),
    CHINA_PETROLEUM_BEIJING("中国石油大学（北京）", new String[]{"211", "双一流"}),
    CHINA_GEOSCIENCES_BEIJING("中国地质大学（北京）", new String[]{"211", "双一流"}),
    TIANJIN_MEDICAL("天津医科大学", new String[]{"211", "双一流"}),
    HEBEI_TECH("河北工业大学", new String[]{"211"}),
    TAIYUAN_TECH("太原理工大学", new String[]{"211", "双一流"}),
    INNER_MONGOLIA("内蒙古大学", new String[]{"211", "双一流"}),
    LIAONING("辽宁大学", new String[]{"211", "双一流"}),
    DALIAN_MARITIME("大连海事大学", new String[]{"211", "双一流"}),
    NORTHEAST_NORMAL("东北师范大学", new String[]{"211", "双一流"}),
    NORTHEAST_AGRI("东北农业大学", new String[]{"211", "双一流"}),
    NORTHEAST_FORESTRY("东北林业大学", new String[]{"211", "双一流"}),
    EAST_CHINA_TECH("华东理工大学", new String[]{"211", "双一流"}),
    DONGHUA("东华大学", new String[]{"211", "双一流"}),
    SHANGHAI_FOREIGN("上海外国语大学", new String[]{"211", "双一流"}),
    SHANGHAI_FINANCE("上海财经大学", new String[]{"211", "双一流"}),
    SHANGHAI_SPORT("上海体育学院", new String[]{"双一流"}),
    SHANGHAI_MUSIC("上海音乐学院", new String[]{"双一流"}),
    NANJING_AGRI("南京农业大学", new String[]{"211", "双一流"}),
    NANJING_TECH("南京理工大学", new String[]{"211", "双一流"}),
    NANJING_AERO("南京航空航天大学", new String[]{"211", "双一流"}),
    JIANGNAN("江南大学", new String[]{"211", "双一流"}),
    NANJING_NORMAL("南京师范大学", new String[]{"211", "双一流"}),
    CHINA_PHARMACEUTICAL("中国药科大学", new String[]{"211", "双一流"}),
    HOHAI("河海大学", new String[]{"211", "双一流"}),
    CHINA_MINING_XUZHOU("中国矿业大学", new String[]{"211", "双一流"}),
    SUZHOU("苏州大学", new String[]{"211", "双一流"}),
    ANHUI("安徽大学", new String[]{"211", "双一流"}),
    HEFEI_TECH("合肥工业大学", new String[]{"211", "双一流"}),
    FUZHOU("福州大学", new String[]{"211", "双一流"}),
    NANCHANG("南昌大学", new String[]{"211", "双一流"}),
    ZHENGZHOU("郑州大学", new String[]{"211", "双一流"}),
    WUHAN_TECH("武汉理工大学", new String[]{"211", "双一流"}),
    HUAZHONG_AGRI("华中农业大学", new String[]{"211", "双一流"}),
    HUAZHONG_NORMAL("华中师范大学", new String[]{"211", "双一流"}),
    ZHONGNAN_FINANCE("中南财经政法大学", new String[]{"211", "双一流"}),
    HUNAN_NORMAL("湖南师范大学", new String[]{"211", "双一流"}),
    SOUTH_CHINA_NORMAL("华南师范大学", new String[]{"211", "双一流"}),
    HAINAN("海南大学", new String[]{"211", "双一流"}),
    GUANGXI("广西大学", new String[]{"211", "双一流"}),
    SOUTHWEST_JIAOTONG("西南交通大学", new String[]{"211", "双一流"}),
    SOUTHWEST_FINANCE("西南财经大学", new String[]{"211", "双一流"}),
    SICHUAN_AGRI("四川农业大学", new String[]{"211", "双一流"}),
    YUNNAN("云南大学", new String[]{"211", "双一流"}),
    XIAN_ELECTRONIC("西安电子科技大学", new String[]{"211", "双一流"}),
    CHANG_AN("长安大学", new String[]{"211", "双一流"}),
    NORTHWEST_NORMAL("西北师范大学", new String[]{"211"}),
    SHAANXI_NORMAL("陕西师范大学", new String[]{"211", "双一流"}),
    XINJIANG("新疆大学", new String[]{"211", "双一流"}),
    SHIHEZI("石河子大学", new String[]{"211", "双一流"}),
    NINGXIA("宁夏大学", new String[]{"211", "双一流"}),
    QINGHAI("青海大学", new String[]{"211", "双一流"}),
    TIBET("西藏大学", new String[]{"211", "双一流"});

    /**
     * 大学名称
     */
    private final String universityName;

    /**
     * 大学类型（可能有多个）
     */
    private final String[] types;

    /**
     * 获取所有985院校
     */
    public static List<String> get985Universities() {
        return Arrays.stream(values())
                .filter(university -> Arrays.asList(university.getTypes()).contains("985"))
                .map(UniversityTypeEnum::getUniversityName)
                .collect(Collectors.toList());
    }

    /**
     * 获取所有211院校
     */
    public static List<String> get211Universities() {
        return Arrays.stream(values())
                .filter(university -> Arrays.asList(university.getTypes()).contains("211"))
                .map(UniversityTypeEnum::getUniversityName)
                .collect(Collectors.toList());
    }

    /**
     * 获取所有双一流院校
     */
    public static List<String> getDoubleFirstClassUniversities() {
        return Arrays.stream(values())
                .filter(university -> Arrays.asList(university.getTypes()).contains("双一流"))
                .map(UniversityTypeEnum::getUniversityName)
                .collect(Collectors.toList());
    }

    /**
     * 判断是否为985院校
     */
    public static boolean is985University(String universityName) {
        return Arrays.stream(values())
                .anyMatch(university -> university.getUniversityName().equals(universityName) &&
                        Arrays.asList(university.getTypes()).contains("985"));
    }

    /**
     * 判断是否为211院校
     */
    public static boolean is211University(String universityName) {
        return Arrays.stream(values())
                .anyMatch(university -> university.getUniversityName().equals(universityName) &&
                        Arrays.asList(university.getTypes()).contains("211"));
    }

    /**
     * 判断是否为双一流院校
     */
    public static boolean isDoubleFirstClassUniversity(String universityName) {
        return Arrays.stream(values())
                .anyMatch(university -> university.getUniversityName().equals(universityName) &&
                        Arrays.asList(university.getTypes()).contains("双一流"));
    }

    /**
     * 根据大学名称获取类型
     */
    public static String[] getUniversityTypes(String universityName) {
        return Arrays.stream(values())
                .filter(university -> university.getUniversityName().equals(universityName))
                .findFirst()
                .map(UniversityTypeEnum::getTypes)
                .orElse(new String[]{"普通本科"});
    }
}